package com.jml.SimpleTomcat;


import java.io.IOException;
import java.io.InputStream;


public class HttpRequest {

	private String uri;

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}


	public HttpRequest(InputStream in)  throws IOException{
		resolverRequest(in);
	}

	private void resolverRequest(InputStream in) throws IOException {

		//1.读取 客户端请求过来的数据，解析出来uri
		byte[] buff = new byte[1024];
		int len = in.read(buff);

		if( len>0 ){
			String msg = new String(buff,0,len);

			System.out.println("客户端请求信息");

			System.out.println("客户端请求过来的数据是:" + msg );

			this.uri = msg.substring( 4,msg.indexOf("HTTP/1.1")  );



		}else{

			System.out.println("bad request!");

		}

	}


	public static void main(String[] args) {

	}



}

